xen/x86: use PCID feature
authorJuergen Gross <jgross@suse.com>
Thu, 26 Apr 2018 11:33:18 +0000 (13:33 +0200)
committerWei Liu <wei.liu2@citrix.com>
Fri, 4 May 2018 14:56:40 +0000 (15:56 +0100)
commit5c81d260c244026ea74632faa3c6d0a00cc76469
tree3dde76ed035e00442e9ea74d54ebcd78b0302b2f
parent1a32c9868711b4ee883ebb6f8807e08d70a920be
xen/x86: use PCID feature

Avoid flushing the complete TLB when switching %cr3 for mitigation of
Meltdown by using the PCID feature if available.

We are using 4 PCID values for a 64 bit pv domain subject to XPTI and
2 values for the non-XPTI case:

- guest active and in kernel mode
- guest active and in user mode
- hypervisor active and guest in user mode (XPTI only)
- hypervisor active and guest in kernel mode (XPTI only)

We use PCID only if PCID _and_ INVPCID are supported. With PCID in use
we disable global pages in cr4. A command line parameter controls in
which cases PCID is being used.

As the non-XPTI case has shown not to perform better with PCID at least
on some machines the default is to use PCID only for domains subject to
XPTI.

With PCID enabled we always disable global pages. This avoids having to
either flush the complete TLB or do a cycle through all PCID values
when invalidating a single global page.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
docs/misc/xen-command-line.markdown
xen/arch/x86/flushtlb.c
xen/arch/x86/mm.c
xen/arch/x86/pv/dom0_build.c
xen/arch/x86/pv/domain.c
xen/include/asm-x86/domain.h
xen/include/asm-x86/processor.h
xen/include/asm-x86/pv/domain.h